package wxdb.parse.absyn;
import java.util.*;

import wxdb.query.*;
import wxdb.symbol.Symbol;

public class UpdtExp extends Exp{
	public Symbol tableName;
	public UpdtLst uclauses;
	public WhereExp where;
	
	private String tblname;
	private Predicate pred;
	private HashMap<String, Expression> hm = new HashMap<String, Expression>();
	private ArrayList<String> namef = new ArrayList<String>();
	private ArrayList<Expression> vs = new ArrayList<Expression>();
	
	public UpdtExp(int p, Symbol t, UpdtLst u, WhereExp w){
		pos = p;
		tableName = t;
		uclauses = u;
		where = w;
		
		tblname = tableName.toString();
		
		pred = new Predicate();
		if(w!=null)
			pred = where.whereList().predicate();
		hm.putAll(uclauses.getNameValues());
		for(String key : hm.keySet()){
			namef.add(key);
			Expression e = hm.get(key);
			vs.add(e);
		}
	}
	
	public String tableName(){
		return tblname;
	}

	public Predicate pred(){
		return pred;
	}
	
	public ArrayList<String> targetFields(){
		return namef;
	}
	
	public ArrayList<Expression> newValues(){
		return vs;
	}
}
